<template>
  <div class="shop">
    <div class="shop-box" @click="navTo(item)">
      <!-- 商品主图 -->
      <div class="shop-box-img">
        <image
          :src="
            'https://copartner.oss-cn-beijing.aliyuncs.com/' +
              item.site_logo || '../../static/image/logo.jpg'
          "
        >
        </image>
      </div>
      <!-- 商品信息 -->
      <div class="shop-box-info">
        <span class="title one_ellipsis">{{
          item.company_name
        }}</span>
        <div class="tip">
          <span class="tip-content one_ellipsis">{{
            item.categorys || "暂无"
          }}</span>
          <span class="tip-sold"
            >已售{{ item.order_count || "0" }}</span
          >
        </div>
        <div class="seg"></div>
        <div class="condition">
          <div class="title time">
            配送时间
            <span class="times"
              >{{ item.open_time | timeFilter }} -
              {{ item.end_time | timeFilter }}</span
            >
          </div>
          <div class="title money">
            <span class="moneys"
              >￥{{ item.starting_price || "0" }}</span
            >起送
          </div>
        </div>
        <div class="address">
          <span class="address-info one_ellipsis"
            >地址：{{ item.company_address || "暂无" }}</span
          >
          <div
            class="iphone"
            @click.stop="call(item.site_phone)"
          >
            <image src="/static/image/iphone.png"></image>
          </div>
        </div>
      </div>
    </div>
    <!-- </div> -->
  </div>
</template>

<script>
import { $https } from "@/static/js/request.js";
export default {
  props: ["datas"],
  data() {
    return {
      // 供应链列表
      item: this.datas,
      // logo: "",
      // showLogo: 0,
    };
  },
  filters: {
    timeFilter: function (value) {
      if (!value) return "暂无";
      return value.slice(0, 5);
    },
  },
  mounted() {
    setTimeout(() => {
      // console.log(this.item);
    }, 2000);
    // this.logo = uni.getStorageSync("logo");
    // this.showLogo = uni.getStorageSync("showLogo");
  },
  methods: {
    // showCart() {
    //   this.$emit("showCart");
    // },
    // pageUrl() {
    //   uni.navigateTo({
    //     url: `../../pages/index/shopdetail?id=${this.data.id}`,
    //   });
    // },
    getUserInfo() {
      return new Promise((resolve, reject) => {
        $https("GETN", "getUserInfo", {}, (res) => {
          if (res.data.errcode == 0) {
            let type = res.data.data.type;
            resolve(type);
          } else {
            reject(res.data.errmsg);
          }
        });
      });
    },
     // 电话
    call(phone){
       uni.makePhoneCall({
          phoneNumber: phone,
          success: (res) => {
          },
          fail: (res) => {
          },
        });
    },
    navTo(row) {
      uni.switchTab({
        url: "/pages/shop/index",
      });
      return 
      let getUserInfo = this.getUserInfo();
      Promise.all([getUserInfo]).then((res) => {
        // type状态为1时代表待审核,状态为2时代表审核成功
        if (res[0] == 2) {
          this.$store.commit("changeCompanyInfo", row);
          uni.switchTab({
            url: "/pages/shop/index",
          });
        } else if (res[0] == 1 || res[0] == 3) {
          uni.showModal({
            title: "提示",
            content: "该账号审核未通过,请联系审核人员进行审核!",
            success: function (res) {
              if (res.confirm && res[0] == 3) {
                uni.navigateTo({
                  url: "/pages/user/qualifications",
                });
              } else if (res.cancel) {
                console.log("用户点击取消");
              }
            },
          });
        } else if (res[0] == 0) {
          uni.showModal({
            title: "提示",
            content: "该账号审核未提交资质审核,请前往资质上传",
            success: function (res) {
              if (res.confirm) {
                uni.navigateTo({
                  url: "/pages/user/qualifications",
                });
              } else if (res.cancel) {
                console.log("用户点击取消");
              }
            },
          });
        }
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.shop {
  width: 100%;
  position: relative;
  margin-top: 20rpx;

  &-box {
    width: calc(100% - 56rpx);
    padding: 10rpx 15rpx;
    margin: 10rpx 15rpx;
    background-color: #fff;
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    margin-bottom: 10rpx;

    &-img {
      width: 162rpx;
      height: 162rpx;
      border-radius: 10rpx;
      padding: 20rpx;

      image {
        width: 100%;
        height: 100%;
      }
    }

    &-info {
      width: calc(100% - 48rpx - 9rpx - 180rpx);
      display: flex;
      flex-direction: column;
      justify-content: space-around;
      margin-left: 9rpx;
      height: 202rpx;

      .title {
        width: 100%;
        font-size: $font_2;
        font-weight: 600;
        font-family: PingFangSC-Medium, PingFang SC;
        color: $color_95;
      }

      .tip {
        width: 100%;
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;

        &-content {
          font-size: $font_4;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: $color_75;
          width: 300rpx;
        }

        &-sold {
          width: 130rpx;
          font-size: $font_4;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: $color_75;
          white-space: nowrap;
          text-align: right;
        }
      }

      .seg {
        width: 100%;
        height: 1rpx;
        background-color: #e5e5e5;
      }

      .condition {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        width: 100%;

        .title {
          font-size: 22rpx;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: $color_75;
          white-space: nowrap;
        }

        .time {
          padding: 6rpx 10rpx;
          background-color: #fff5e7;
          width: 260rpx;
        }

        .times {
          color: $picre_c;
          margin-left: 10rpx;
        }

        .money {
          width: 160rpx;
          text-align: right;
        }

        .moneys {
          color: $picre_c;
          margin-right: 10rpx;
        }
      }

      .address {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        width: 100%;

        &-info {
          width: 380rpx;
          font-size: 26rpx;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: $color_75;
        }

        .iphone {
          width: 38rpx;
          height: 38rpx;
          display: flex;
          justify-content: center;
          align-items: center;

          image {
            width: 80%;
            height: 80%;
          }
        }
      }
    }
  }
}
</style>
